<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of DAL_ReportWongWord
 *
 * @author Administrator
 */
class DAL_ReportWongWord {

    //put your code here

    public static function insert($ReportWongWord) {
        $p = array(
//                    ":wordid"=>$ReportWongWord->wordid,
//                    ":word"=>$ReportWongWord->word,
//                    ":read"=>$ReportWongWord->read,
//                    ":species"=>$ReportWongWord->species,
//                    ":meaning"=>$ReportWongWord->meaning,
//                    ":reportuserid"=>$ReportWongWord->reportuserid,
//                    ":reportusername"=>$ReportWongWord->reportusername,
//                    ":reportdate"=>$ReportWongWord->reportdate,
//                    ":remark"=>$ReportWongWord->remark,
        );

        //未完成
//$sql="insert into userMemory (userid,username,wordid,memory) values(:userid,:username,:wordid,:memory)";
        if ($ReportWongWord->wordid != null && $ReportWongWord->wordid != "") {
            $p[":wordid"] = $ReportWongWord->wordid;
        }
        if ($ReportWongWord->word != null && $ReportWongWord->word != "") {
            $p[":word"] = $ReportWongWord->word;
        }
        if ($ReportWongWord->read != null && $ReportWongWord->read != "") {
            $p[":read"] = $ReportWongWord->read;
        }
        if ($ReportWongWord->species != null && $ReportWongWord->species != "") {
            $p[":species"] = $ReportWongWord->species;
        }
        if ($ReportWongWord->meaning != null && $ReportWongWord->meaning != "") {
            $p[":meaning"] = $ReportWongWord->meaning;
        }
        if ($ReportWongWord->reportuserid != null && $ReportWongWord->reportuserid != "") {
            $p[":reportuserid"] = $ReportWongWord->reportuserid;
        }

        if ($ReportWongWord->reportusername != null && $ReportWongWord->reportusername != "") {
            $p[":reportusername"] = $ReportWongWord->reportusername;
        }
        if ($ReportWongWord->reportdate != null && $ReportWongWord->reportdate != "") {
            $p[":reportdate"] = $ReportWongWord->reportdate;
        }
        if ($ReportWongWord->remark != null && $ReportWongWord->remark != "") {
            $p[":remark"] = $ReportWongWord->remark;
        }

        $cols = "";
        $val = "";
        foreach ($p as $key => $value) {
            $cols.=trim($key, ":") . ",";
            $val.=$key . ",";
        }
        $cols = trim($cols, ",");
        $val = trim($val, ",");

        $sql = "insert into reportwrongword ($cols) values($val)";

        //echo $sql;

        $s = new SqliteHelper();
        $s->ExecNoTans($sql, $p);
    }

}

?>
